﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Bing4Free
{
	class Bing4FreeSettings
	{
		public static Bing4Free.Properties.Settings settings;

		public static void Load()
		{
			settings = Bing4Free.Properties.Settings.Default;

			// Default wallpapers folder
			if (settings.PicturesFolder == null || settings.PicturesFolder.Length == 0)
			{
				settings.PicturesFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\Bing4Free";
				settings.Save();
			}

			// Default update interval
			if (settings.UpdateInterval == null || settings.UpdateInterval.Length == 0)
			{
				settings.UpdateInterval = "300000";
				settings.Save();
			}

			// Default switch interval
			if (settings.SwitchInterval == null || settings.SwitchInterval.Length == 0)
			{
				settings.SwitchInterval = "300000";
				settings.Save();
			}

			// Default max item
			if (settings.MaxItem == null || settings.MaxItem.Length == 0)
			{
				settings.MaxItem = "10";
				settings.Save();
			}

			// Default wallpaper style
			if (settings.WallpaperStyle == null || settings.WallpaperStyle.Length == 0)
			{
				DesktopBackgroundStyle wallpaperStyle = WindowsAPI.GetCurrentDesktopWallpaperBackgroundStyle();
				string style = "0";

				switch (wallpaperStyle)
				{
					case DesktopBackgroundStyle.Centered:
						style = "1";
						break;
					case DesktopBackgroundStyle.Tiled:
						style = "2";
						break;
					case DesktopBackgroundStyle.Stretched:
					default:
						style = "0";
						break;
				}

				settings.WallpaperStyle = style;
				settings.Save();
			}
		}
	}
}
